<!DOCTYPE html>
<html lang="zh-CN" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head th:include="/common/inc::header"/>
<body>
<form class="layui-form" style="margin-top: 15px">
    <div class="layui-form-item">
        <label class="layui-form-label" style="width: 80px">创建时间:</label>
        <div class="layui-input-inline" style="width:7%">
            <input type="text" class="layui-input" id="addTimeSt" name="addTimeSt">
        </div>
        <div class="layui-input-inline" style="width:7%">
            <input type="text" class="layui-input" id="addTimeEt" name="addTimeEt">
        </div>
        <button class="layui-btn" id="searchBtn" lay-submit lay-filter="searchBtn">查询</button>
    </div>
</form>
<table class="layui-table" id="grid" lay-filter="grid">
</table>
<script th:replace="/common/inc::incJs"></script>
<script>
    var tableIns;

    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#addTimeSt', //指定元素
            format: 'yyyy-MM-dd'
        });
        //执行一个laydate实例
        laydate.render({
            elem: '#addTimeEt', //指定元素
            format: 'yyyy-MM-dd'
        });

    });

    $(function () {
        tableIns = createTable({
            url: '/agent/security/bdTeam/bdStatisticsList',
            cols: [[{field: 'parentBdId', title: '代理商编号', width: 150},
                {field: 'remark', title: '代理商名称', width: 180}
                , {field: 'amount', title: '推广人数', width: 150}, {
                    fixed: 'right',
                    title: '操作',
                    width: 180,
                    align: 'center',
                    toolbar: '#opbar'
                }
            ]]
        });
    });

    layui.table.on('tool(grid)', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
        var data = obj.data; //获得当前行数据
        var layEvent = obj.event; //获得 lay-event 对应的值
        var tr = obj.tr; //获得当前行 tr 的DOM对象02\

        if (layEvent === 'customerInfo') { //
            openDialog({
                url: "/agent/security/bdTeam/statisticsDetail?parentBdId=" + data.parentBdId,
                area: ["90%", "90%"]
            });
        }
    });

    layui.form.on('submit(searchBtn)', function (data) {
        tableIns.reload({
            where: data.field
        });
        return false;
    });

</script>
<script type="text/html" id="opbar">
    <a class="layui-btn layui-btn-xs" lay-event="customerInfo">查看推广人员</a>
</script>
</body>
</html>
